package net.atomarrow.configs;

import net.atomarrow.db.pool.IDataSource;


/**
 * 数据库相关配置
 * @author Michael
 *
 */
public class DbConfig {

    //TODO need finish this
    public static final String DB_TYPE_MYSQL = "mysql";
    public static final String DB_TYPE_ORACLE = "oracle";
    
    private IDataSource dataSource;
    private static String databaseName;
    private static String dabaseType;

    public  static String getDatabaseName() {
        return databaseName;
    }
    public static String getDatabaseType(){
        return dabaseType;
    }

    
    public IDataSource getDataSource(){
        return dataSource;
    }
    
    public void closeDataSourse(){
    	if(dataSource!=null){
    		dataSource.stop();
    	}
    }

    public void loadConfig(Config config) {
//    	dataSource=new C3p0DataSource("jdbc:mysql://localhost/atomarrow", "root", "root").getDataSource();
//    	databaseName = "atomarrow";
        dataSource=config.configDbPool();
        databaseName=config.configDbName();
        dabaseType=config.configDbType();
    }
}
